package com.hlkj.log4j;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.PropertyConfigurator;

public class Log4jInitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void service(ServletRequest req, ServletResponse resp)
			throws ServletException, IOException {
	}

	public void init() throws ServletException {
		System.setProperty("log4jPath", getServletContext().getRealPath("/")
				 + "myLog.log");
		System.err.println("Log4j Servlet Path: "
				+ System.getProperty("log4jPath"));
		PropertyConfigurator.configure(getServletContext().getRealPath("/")
				+ getInitParameter("configfile"));
	}
}
